#include "../libgf_math/gf_math.h"
#include "../libprop_tester/prop_tester.h"

int equivTest(unsigned char *a) {
	bool rejected;
	unsigned char sbox[16] = {0xC, 0x5, 0x6, 0xB, 0x9, 0x0, 0xA, 0xD, 0x3,
				  0xE, 0xF, 0x8, 0x4, 0x7, 0x1, 0x2};

	for(int b = 0; b < 16; ++b) {
		rejected = false;

		for(int i = 0; i < 16; ++i) {
			if(gf_add(gf_mult(sbox[i], a[i]), b) != sbox[i]) {
				rejected = true;
				break;	
			}
		}

		if(rejected == false)
			return 0;
	}

	return 1;
}

int main() {
	char filename[] = "equiv_gen.bin";

	return propTester(equivTest, filename);
}
